#pragma once

#include "../object.h"

  namespace one_rag {
  #ifdef _WIN32

  namespace detail {

    struct Win32WindowClass {
      union {
        ATOM classAtom;
        LPCTSTR className;
      };
      operator LPCTSTR(){return className;}
      Win32WindowClass(ATOM atm){classAtom=atm;}
      Win32WindowClass(LPCTSTR str){className=str;}
    };

    class Win32Window : public Object
    {
    protected:
        HWND _wnd;
    public:
      Win32Window();
      ~Win32Window();
      operator HWND();

      HWND CreateOverlapped(ATOM classId,int x,int y,int w,int h,LPCTSTR strTitle,HMENU hMenu=0);
      HWND CreateMacBar(ATOM classId, int x, int y, int w, int h, LPCTSTR strTitle,HMENU hMenu=0);
      HWND CreateControl(ATOM classId,int x, int y, int w, int h, INT cltId);
      ATOM RegisterClass(LPCTSTR strClass,HBRUSH hbr=NULL);
      ATOM RegisterClass(LPCTSTR strClass,UINT color){return RegisterClass(strClass,HBRUSH(color+1));}

      SIZE GetClientSize();

      //Win32 api
      HWND Create(Win32Window& parent,ATOM atm,int x=0, int y=0, int w=-1, int h=-1,UINT id=-1,LPCSTR strTitle=NULL,DWORD style=WS_CHILD,DWORD styleEx=0L);
      UINT SetTimer(DWORD ms,UINT id=0);

    protected:
      static LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
      virtual LRESULT WindowProc(UINT uMsg,WPARAM wParaml,LPARAM lParam);
    };
    typedef Win32Window Window;
    typedef Win32Window View;

    // inlines

    inline Win32Window::operator HWND(){
      return _wnd;
    }
  }

#endif
}
